import { Thing } from "./thing";

import { Scene, PlaneGeometry, TextureLoader, RepeatWrapping, Vector3 } from 'three';

import { Sun } from "./sun";
import { Sky } from "three/examples/jsm/objects/Sky";

export class SkyThing extends Thing{

    sky: Sky;
    
    constructor(scene: Scene, sun: Sun) {
        super(scene, sun);
        // 天空
        const sky = this.sky = new Sky();
        sky.scale.setScalar(10000);

        const skyUniforms = sky.material.uniforms;

        skyUniforms['turbidity'].value = 10;
        skyUniforms['rayleigh'].value = 2;
        skyUniforms['mieCoefficient'].value = 0.002;  // 太阳光晕大小
        skyUniforms['mieDirectionalG'].value = 0.8;

        this._scene?.add(this.sky);

    }

    update() {
        this.sky.material.uniforms['sunPosition'].value.copy(this._sun.vector);
    }



}